package com.itheima.es.web;

import com.hmall.common.dto.PageDTO;
import com.hmall.common.es.ItemDoc;
import com.itheima.es.service.ItemSearchService;
import com.itheima.es.vo.SearchVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * @author 苏成博
 * @date 2023-03-18 19:06
 */
@RestController
@RequestMapping("/search")
public class ItemSearchController {
    @Autowired
    private ItemSearchService itemSearchService;
    @PostMapping("/list")
    public PageDTO<ItemDoc> listSearchItem(@RequestBody SearchVO searchVO){
        PageDTO<ItemDoc> pageDTO=itemSearchService.listSearchItem(searchVO);
        return pageDTO;
    }
    @PostMapping("/filters")
    public Map<String,List<String>> filterSearch(@RequestBody SearchVO searchVO){
        Map<String,List<String>> map= itemSearchService.filterSearch(searchVO);
        return map;
    }
}